package com.sj.parksdk.net.http;

import com.sj.parksdk.net.base.CommonResult;
import com.sj.parksdk.net.result.databean.Data_CarLicense;
import com.sj.parksdk.net.result.databean.Data_Ocr_ID;
import com.sj.parksdk.net.result.databean.Data_PackageOrder;
import com.sj.parksdk.net.result.databean.Data_ParkRecord;
import com.sj.parksdk.net.result.databean.Data_PrePayment;
import com.sj.parksdk.net.result.databean.Data_Token;
import com.sj.parksdk.net.result.databean.Data_VertifyCode;
import com.sj.parksdk.net.result.databean.Data_Weipay_Native;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.GET;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;
import retrofit2.http.Url;

/**
 * 使用的是retrofit的接口定义
 */
public class MyRetorfitApi {

    public interface TokenService {
        @POST(MyNetApi.TOKEN_ANONYMOUS)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_Token>> anonymous(@Body MyNetApi.Cetificat param);

        @POST(MyNetApi.LOGIN_LOGIN)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_Token>> login(@Body RequestBody jsonBody);

        @POST(MyNetApi.TOKEN_REFRES_TOKEN)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_Token>> refresh(@Body MyNetApi.RefreshToken params);
    }

    public interface CarService{
        @POST(MyNetApi.CAR_ADD_CAR)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> add(@Header("Authorization")String token,@Body MyNetApi.CarAdd car);

        @POST
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> delete(@Url String url, @Header("Authorization")String token);
    }

    public interface CouponsService{
        @POST(MyNetApi.USER_COUPONS_RECEIVE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> receive(@Header("Authorization")String token,@Body MyNetApi.CouponsReceive coupons);
    }

    public interface LoginService{
        @POST(MyNetApi.LOGIN_SENG_MESSAGE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> send(@Body MyNetApi.LoginPone phone);

        @POST(MyNetApi.LOGIN_PHONE_LOGIN)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_Token>> phoneLogin(@Body MyNetApi.LoginPone param);

        @POST(MyNetApi.LOGIN_VERTIFY_CODE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_VertifyCode>> verify(@Body MyNetApi.LoginPone param);

        @POST(MyNetApi.LOGIN_RESET_PASSWORD)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> resetPassword(@Header("Authorization")String token,@Body MyNetApi.UpdatePassword param);

        @POST(MyNetApi.LOGIN_OUT)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> logout(@Header("Authorization")String token,@Body MyNetApi.RefreshToken param);
    }

    public interface OCRService{
        /**
         * ocr图片识别
         */
        @Multipart
        @POST()
        Observable<CommonResult<Data_Ocr_ID>> ocridcard(@Url String url,@Header("Authorization")String token, @Part MultipartBody.Part file);

        @Multipart
        @POST()
        Observable<CommonResult<Data_CarLicense>> ocrwehiclelicense(@Url String url, @Header("Authorization")String token, @Part MultipartBody.Part file);
    }

    public interface VerifyService{
        @POST(MyNetApi.USER_CERtiFICATE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> idverify(@Header("Authorization")String token,@Body MyNetApi.UserCertificate param);

        @POST()
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> carVerify(@Url String url,@Header("Authorization")String token,@Body MyNetApi.CarCertificate param);
    }

    public interface OrderService{
        @GET(MyNetApi.ORDER_CALCULATEPRICE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_ParkRecord>> calculatePrice(@Header("Authorization")String token, @Path("orderNo") String orderNo, @Query("couponId") Long couponId);

        @POST(MyNetApi.PACKAGE_CREATE_ORDER)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_PackageOrder>> packageCreateOrder(@Header("Authorization")String token, @Body MyNetApi.PackageCreateOrderBody params);

    }

    public interface PayService{
        @POST(MyNetApi.PAY_FREETRADE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult> payFreeTrade(@Header("Authorization")String token, @Body MyNetApi.Pay params);

        @POST(MyNetApi.PAY_PREPAYMENT)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_PrePayment>> prepayment(@Header("Authorization")String token, @Body MyNetApi.PrePay params);

        @POST(MyNetApi.PAY_WEIPAY_QRCODE)
        @Headers({"Content-Type: application/json", "Accept: application/json"})
        Observable<CommonResult<Data_Weipay_Native>> weipaynative(@Header("Authorization")String token, @Body MyNetApi.Pay params);
    }

}
